import com.mapper.SStudentMapper;
import com.pojo.SStudent;
import com.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class SStudentTest {
        @Test
        public void selectStudentsByIdTest(){
            SqlSession session = MyBatisUtils.getSession();
            SStudentMapper mapper = session.getMapper(SStudentMapper.class);
            SStudent students = mapper.selectSStudentById(2);
            System.out.println(students);
            session.close();
        }

        @Test
        public void updateStudentsTest(){
            SqlSession session = MyBatisUtils.getSession();
            SStudentMapper mapper = session.getMapper(SStudentMapper.class);
            com.pojo.SStudent students = new SStudent();
            students.setId(4);
            students.setName("李雷");
            students.setAge(21);
            int result = mapper.updateStudents(students);
            if (result>0){
                System.out.println("成功插入"+result+"条数据");
            }else {
                System.out.println("插入数据失败");
            }
            System.out.println(students.toString());
            session.commit();
            session.close();
        }
    }
